//
//  MayMainTabBarController.swift
//  simulateWeibo
//
//  Created by May on 16/7/18.
//  Copyright © 2016年 May. All rights reserved.
//

import UIKit

class MayMainTabBarController: UITabBarController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        addChildViewControllers()
    }
    
    ///添加子控制器
    func addChildViewControllers() {
        //添加子控制器
        //首页   创建一个首页的控制器
        let homeVC =  MayHomeTableViewController()
        self.addChildViewController(homeVC, title:  "首页", imageName:  "tabbar_home")
        
        //消息
        let messageVC =  MayMessageTableViewController()
        self.addChildViewController(messageVC, title: "消息", imageName: "tabbar_message_center")
        
        //发现
        let discoveryVC =  MayDiscoveryTableViewController()
        self.addChildViewController(discoveryVC, title: "发现", imageName: "tabbar_discover")
        
        //我
        let profileVC =  MayProfileTableViewController()
        self.addChildViewController(profileVC, title: "我", imageName: "tabbar_profile")
    }
    
    ///添加自控制器，包装导航控制器
    func addChildViewController(controller: UIViewController, title: String, imageName: String) {
        //设置标题图片和标题
        controller.title = title
        controller.tabBarItem.image = UIImage(named:imageName)
        self.addChildViewController(UINavigationController(rootViewController: controller))
    }
    
}
